//
//  YZCConsultImageCell.m
//  LOLerBox
//
//  Created by 杨智超 on 16/1/16.
//  Copyright © 2016年 蓝鸥科技. All rights reserved.
//

#import "YZCConsultImageCell.h"
#import <UIImageView+WebCache.h>
@implementation YZCConsultImageCell

- (void)awakeFromNib {
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.titleLabel = [[UILabel alloc]init];
        self.titleLabel.font = [UIFont systemFontOfSize:16];
        [self.contentView addSubview:self.titleLabel];
        [_titleLabel release];
        
        self.descLabel = [[UILabel alloc]init];
        self.descLabel.textColor = [UIColor grayColor];
        self.descLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.descLabel];
        [_descLabel release];
        
        self.picImageView = [[UIImageView alloc]init];
        self.picImageView.backgroundColor = [UIColor cyanColor];
        [self.contentView addSubview:self.picImageView];
        [_picImageView release];
        
        self.playImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"play@2x"]];
        self.playImageView.center = self.picImageView.center;
        [self.picImageView addSubview:self.playImageView];
        [_playImageView release];
        
        self.publishedLabel = [[UILabel alloc]init];
        /* 字体右对齐 */
        self.publishedLabel.textAlignment = UITextAlignmentRight;
        self.publishedLabel.font = [UIFont systemFontOfSize:10];
        self.publishedLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:self.publishedLabel];
        [_publishedLabel release];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    _picImageView.frame = CGRectMake(10, 10, 80, 60);
    _titleLabel.frame = CGRectMake(100, 20, 270, 15);
    _descLabel.frame = CGRectMake(100, 45, 270, 12);
    _playImageView.frame = CGRectMake(25, 15, 30, 30);
    _publishedLabel.frame = CGRectMake(300, 65, 70, 10);
    
}

- (void)setModel:(YZCConsultModel *)model {
    if (model != _model) {
        _model = model;
    }
    _model.title = _titleLabel.text;
    _model.desc = _descLabel.text;
    NSString *published = _model.published.description;
    published = _publishedLabel.text;
    [_picImageView sd_setImageWithURL:[NSURL URLWithString:model.pic_url]];
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
